//
//  LGSearchResultViewController.m
//  LuxuryGoods
//
//  Created by 纳里健康 on 2018/5/29.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGSearchResultViewController.h"
#import "NDPageConfig.h"
#import "NDPageViewController.h"
#import "LGResultListViewController.h"
#import "LGGoodsModel.h"


@interface LGSearchResultViewController ()<NDPageViewControllerDelegate>
{
    NSMutableArray *_ViewControllersArray;
}

@end

@implementation LGSearchResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self makeMenu];
}

- (void)getGoodsData
{
//    [[MainApi sharedInstance] getPath:@"Goods/getList" params:@{@"is_recom":@"0"} resultBlock:^(NSDictionary *responseObject, NSError *error) {
//        NSInteger code = [responseObject[@"code"] integerValue];
//        
//        if(code == 1)
//        {
//            dispatch_group_leave(self->_group);
//            
//            NSDictionary *dict = responseObject[@"data"];
//            
//            NSArray *goodArray = dict[@"goods_list"];
//            
//            for (NSDictionary *goodDict in goodArray) {
//                
//                LGGoodsModel *model = [LGGoodsModel yy_modelWithJSON:goodDict];
//                
//                [self.productDataArray addObject:model];
//            }
//            
//            [self.collectionView reloadData];
//        }
//        
//    }];

}


-(void)makeMenu
{
    NDPageConfig *config = [[NDPageConfig alloc]init];
    config.barBtnWidth = SCREEN_WIDTH/4;
    config.barViewH = 40;
    config.nomalColor = TEXT_COLOR_2;
    config.selectColor = TOPCAIL_COLOR;
    config.nomalFont = [UIFont systemFontOfSize:15];
    config.selectFont = [UIFont systemFontOfSize:15];
    config.lineWidth = SCREEN_WIDTH/4;
    config.lineHight = 0;
    config.lineColor = TOPCAIL_COLOR;
    
    config.openImage = [UIImage imageNamed:@"Up"];
    config.closeImage = [UIImage imageNamed:@"Down"];
    config.backColor = WHITE_COLOR;
    
    _ViewControllersArray = @[].mutableCopy;
    
    for (int i = 0; i < 4; i ++) {
        
        LGResultListViewController *resultVC = [[LGResultListViewController alloc] init];
        
        resultVC.Type = (searchType)i;
        
        resultVC.index = i;
        [_ViewControllersArray addObject:resultVC];
    }
    
    //综合 价格  上新  筛选
    NDPageViewController *pageViewController = [[NDPageViewController alloc]initWithClassArray:_ViewControllersArray titleArray:@[@"综合",@"价格",@"上新",@"筛选"] config:config];
    
    pageViewController.delegate = self;
    
    [self addChildViewController:pageViewController];
    pageViewController.view.frame = self.view.bounds;
    [self.view addSubview:pageViewController.view];

    
}

-(void)pageViewOpenMenuAtIndex:(NSInteger)index
{
    if(index == 2)
    {
        LGResultListViewController *resultVC = _ViewControllersArray[index];
        resultVC.Type = priceDowmType;
        [resultVC requestData];
    }
}

-(void)pageViewCloseMenuAtIndex:(NSInteger)index
{
    if(index == 2)
    {
        LGResultListViewController *resultVC = _ViewControllersArray[index];
        resultVC.Type = priceupType;
        
        [resultVC requestData];
    }
}

-(void)pageViewSelectAtIndex:(NSInteger)index
{
    NSLog(@"------- %ld",(long)index);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
